package com.greenline.push.service.core.counter;

import java.util.concurrent.atomic.AtomicInteger;

/**
 * 
 * @Type CounterInstance
 * @Desc 计数器
 * @author shuai.zuo
 * @date 2014年10月13日
 * @Version V1.0
 */
public class CounterInstance {
    private AtomicInteger count = new AtomicInteger(0);

    // 并非是单例<每个渠道配一个>
    public static CounterInstance getInstance() {
        return new CounterInstance();
    }

    public void reset() {
        count.set(0);
    }

    public void log() {
        int called = count.get();
        // log.info(called);
        // save db?
        // TODO
        System.out.println(called);
    }

    public void called() {
        count.incrementAndGet();
    }

}
